﻿using TestBat.Models.Domain;

namespace TestBat.Models.Tests.Mocks.Models.Domain
{
    public class AssociatedTestObject : DomainEntity
    {
        public virtual string AssociatedTestValue { get; set; }

        public virtual TestObject TestObject
        {
            get { return testobject; }
            set
            {
                if (Equals(testobject, value))
                    return; // no change needed

                if (testobject != null)
                    testobject.AssociatedTestObjects.Remove(this); // remove from old object

                testobject = value;

                if (testobject != null)
                    testobject.AssociatedTestObjects.Add(this); // add to new object
            }
        }

        private TestObject testobject;
    }
}
